package com.quick.domain;

import com.singularsys.jep.Jep;

import java.math.BigDecimal;

/**
 * @author wangxin86
 * @title: Taa
 * @description: TODO
 * @date 2019/8/22 10:49
 */
public class Taa {
    public static void main(String[] args) throws Exception {


//        String exp = "X*(6/106)";
//        JEP jep = new JEP();
//        jep.addVariable("X",2.9934);
//        jep.parseExpression(exp);
//        BigDecimal result = new BigDecimal((Double) jep.getValueAsObject());
//        System.out.println(result);
//        System.out.println(result.setScale(2, BigDecimal.ROUND_HALF_UP));

        String exp = "-X*(6/106)";
        Jep jep = new Jep();
        BigDecimal a = new BigDecimal("1.00");
        jep.addVariable("X", a);
        jep.parse(exp);
        System.out.println(jep.evaluate());
        BigDecimal result = new BigDecimal((Double) jep.evaluate()).setScale(2, BigDecimal.ROUND_HALF_UP);
        System.out.println(result);
        System.out.println(result.compareTo(BigDecimal.ZERO));
    }
}
